package yf.mall.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import yf.mall.entity.LevelRecordEntity;
import yf.mall.service.LevelRecordService;
import com.yf.response.R;


/**
 * 级别记录Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Jul 21 13:28:36 CST 2020
 */
@RestController
@RequestMapping("/level/record")
public class LevelRecordController {
    @Autowired
    private LevelRecordService levelRecordService;

    /**
     * 列表级别记录
     */
    @SysLog("查看级别记录")
    @RequestMapping("/list")
    @RequiresPermissions("level:record:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<LevelRecordEntity> levelRecordList = levelRecordService.queryList(params);
        return R.ok(new PageInfo(levelRecordList));
    }

    /**
     * 查看级别记录
     */
    @SysLog("查看级别记录")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("level:record:info")
    public R info(@PathVariable("id") Long id) {
        LevelRecordEntity levelRecord = levelRecordService.get(id);

        return R.ok(levelRecord);
    }

    /**
     * 保存级别记录
     */
    @SysLog("保存级别记录")
    @RequestMapping("/save")
    @RequiresPermissions("level:record:save")
    public R save(LevelRecordEntity levelRecord) {
        levelRecordService.save(levelRecord);

        return R.ok(levelRecord);
    }

    /**
     * 修改级别记录
     */
    @SysLog("修改级别记录")
    @RequestMapping("/update")
    @RequiresPermissions("level:record:update")
    public R update(LevelRecordEntity levelRecord) {
        levelRecordService.update(levelRecord);

        return R.ok(levelRecord);
    }

    /**
     * 删除级别记录
     */
    @SysLog("删除级别记录")
    @RequestMapping("/delete")
    @RequiresPermissions("level:record:delete")
    public R delete(Long[]ids) {
        levelRecordService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有级别记录
     */
    @SysLog("所有级别记录")
    @RequestMapping("/all")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<LevelRecordEntity> levelRecordList = levelRecordService.queryList(params);

        return R.ok(levelRecordList);
    }

    /***********自定义开始***********/
}
